import { createRouter, createWebHistory } from "vue-router";

import App from "../components/layout/App";
import Nopage from "../components/layout/nopage";

export default function routerInstance(children = [], others = []) {
    return createRouter({
        history: createWebHistory(),
        routes: [
            {
                path: "/home",
                name: "home",
                component: App,
                children: [
                    ...children,
                    // {
                    //     path: "announce/list",
                    //     name: "announceList",
                    //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/test")
                    //     // component: () => import(/* webpackChunkName: "notice" */ "../components/homepage/home")
                    // },
                    {
                        path: "announce/list",
                        name: "announceList",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/announce/index")
                    },
                    {
                        path: "announce/detail",
                        name: "announceDetail",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/announce/detailmodal")
                    },
                    {
                        path: "notice/list",
                        name: "noticeList",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/list/index")
                    },
                    {
                        path: "notice/list/detail",
                        name: "noticeDetail",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/list/detail")
                    },
                    {
                        path: "notice/template",
                        name: "noticeTemplate",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/template/index")
                    },
                    {
                        path: "notice/template/update/:type",
                        name: "noticeTemplateUpdate",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/template/update")
                    },
                    {
                        path: "notice/rules",
                        name: "noticeRules",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/index")
                    },
                    {
                        path: "notice/rules/update/:type",
                        name: "noticeRulesUpdate",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/update")
                    },
                    {
                        path: "notice/rules/test",
                        name: "noticeRulesTest",
                        component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/test")
                    },
                    {
                        path: "nopage",
                        name: "nopage",
                        component: Nopage
                    }
                ]
            },
            ...others,
            {
                path: "/",
                redirect: { name: "home" }
            },
            {
                path: "/:pathMatch(.*)*",
                redirect: { name: "nopage" }
            }
        ]
    })
}

// export default createRouter({
//     history: createWebHistory(),
//     routes: [
//         {
//             path: "/home",
//             name: "home",
//             component: App,
//         },
//         {
//             path: "/nopage",
//             name: "nopage",
//             component: Nopage
//         },
//         {
//             path: "/",
//             redirect: { name: "home" }
//         },
//         {
//             path: "/:pathMatch(.*)*",
//             redirect: { name: "nopage" }
//         }
//     ],
// })

// export default function routerInstance(children = [], others = []) {
//     return createRouter({
//         history: createWebHistory(),
//         routes: [
//             {
//                 path: "/home",
//                 name: "home",
//                 component: App,
//                 children: [
//                     ...children,
//                     // {
//                     //     path: "announce/list",
//                     //     name: "announceList",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/announce/index")
//                     // },
//                     // {
//                     //     path: "announce/detail",
//                     //     name: "announceDetail",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/announce/detailmodal")
//                     // },
//                     // {
//                     //     path: "notice/list",
//                     //     name: "noticeList",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/list/index")
//                     // },
//                     // {
//                     //     path: "notice/list/detail",
//                     //     name: "noticeDetail",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/list/detail")
//                     // },
//                     // {
//                     //     path: "notice/template",
//                     //     name: "noticeTemplate",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/template/index")
//                     // },
//                     // {
//                     //     path: "notice/template/update/:type",
//                     //     name: "noticeTemplateUpdate",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/template/update")
//                     // },
//                     // {
//                     //     path: "notice/rules",
//                     //     name: "noticeRules",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/index")
//                     // },
//                     // {
//                     //     path: "notice/rules/update/:type",
//                     //     name: "noticeRulesUpdate",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/update")
//                     // },
//                     // {
//                     //     path: "notice/rules/test",
//                     //     name: "noticeRulesTest",
//                     //     component: () => import(/* webpackChunkName: "notice" */ "../views/notice/rules/test")
//                     // },
//                     {
//                         path: "nopage",
//                         name: "nopage",
//                         component: Nopage
//                     }
//                 ]
//             },
//             ...others,
//             {
//                 path: "/",
//                 redirect: { name: "home" }
//             },
//             {
//                 path: "/:pathMatch(.*)*",
//                 redirect: { name: "nopage" }
//             }
//         ]
//     })
// }